/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package biofilter.util;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author t9i
 */
public class SystemPropertiesTest {

    public SystemPropertiesTest() {
    }

    @BeforeClass
    public static void setUpClass() throws Exception {
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
    }

    @Before
    public void setUp() {
    }

    @After
    public void tearDown() {
    }

    /**
     * Test of getSystemProperties method, of class SystemProperties.
     */
    @Test
    public void testGetSystemProperties() {
        System.out.println("getSystemProperties");
        SystemProperties result = null;
        try {
            result = new SystemProperties();
        } catch (IOException ex) {
            Logger.getLogger(SystemPropertiesTest.class.getName()).log(Level.SEVERE, null, ex);
            System.out.println("exception caught");
        }
        assertEquals("SystemProperties", result.getClass().getSimpleName());
        // TODO review the generated test code and remove the default call to fail.
        //fail("The test case is a prototype.");
    }


    @Test(expected=FileNotFoundException.class)
    public void testSetFile() throws IOException  {
        System.out.println("setFile");
        String file = "/path/to/invalid/file";
        SystemProperties.setFile(file);
        SystemProperties instance = null;
        instance = new SystemProperties();
    }



    /**
     * Test of get method, of class SystemProperties.
     */
    @Test
    public void testGet() {
        System.out.println("get");
        String key = "";
        SystemProperties.setFile("test/testdata/sys.properties");
        SystemProperties instance = null;
        try {
            instance = new SystemProperties();
        } catch (IOException ex) {
            Logger.getLogger(SystemPropertiesTest.class.getName()).log(Level.SEVERE, null, ex);
            System.out.println("exception caught");
        }
        String expResult = null;
        String result = instance.get(key);
        assertEquals(expResult, result);
        // TODO review the generated test code and remove the default call to fail.
        //fail("The test case is a prototype.");

    }

    @Test
    public void testGet2() {
        System.out.println("get");
        String key1 = "key1";
        String key2 = "key2";
        String key3 = "KEY3";
        String key4 = "key3";

        SystemProperties instance = null;
        try {
            instance = new SystemProperties();
        } catch (IOException ex) {
            Logger.getLogger(SystemPropertiesTest.class.getName()).log(Level.SEVERE, null, ex);
            System.out.println("exception caught");
        }

        assertEquals("value1", instance.get(key1));
        assertEquals("value2", instance.get(key2));
        assertEquals("VALUE3", instance.get(key3));
        assertEquals(null, instance.get(key4));


    }

}